<!DOCTYPE html>
<html lang="en">
<head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
</head>
<style>
 #obj{
   width:100px;
   height:100px;
   background-color:yellowgreen;
   position:absolute
 }
 #s{
   background-color:rebeccapurple;
   position: relative;
   width:50px;
   height:100px;
 }
</style>
<script>
  window.onload=function(){
  var count=document.getElementById("count");
  var num=1;
  //定时器调用
  /*var time=setInterval(function(){
    count.innerHTML=num++;
    if(num==11){
      //清除定时器
clearInterval(time);
 }
  },1000);*/
//延时调用，只执行一次.
  var t=setTimeout(function(){
console.log(num++);
  },1000);
  clearTimeout(t);//清除延时器
  }
 </script>
<body>
  <h2 id="count">1</h2>
</body>
</html>                                                                                                                                 